﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for Social_Discussion
/// </summary>
public class Social_Discussion
{
	public Social_Discussion()
	{
	}

    public DataSet BindData(int pid)
    {
        SqlConnection cn = new SqlConnection(YAF.Classes.Config.ConnectionString);
        cn.Open();

        //  SqlCommand cmd = new SqlCommand("social_discussions_get", cn);
        //   cmd.CommandType = CommandType.StoredProcedure;

        SqlDataAdapter adap = new SqlDataAdapter("social_discussions_get", cn);
        adap.SelectCommand.CommandType = CommandType.StoredProcedure;
        adap.SelectCommand.Parameters.AddWithValue("pid", pid);
        DataSet ds = new DataSet();
        adap.Fill(ds, "social_discussions_get");
        cn.Close();
        return ds;
    }

    public void PostComment(int pid, String txt)
    {
        SqlConnection cn = new SqlConnection(YAF.Classes.Config.ConnectionString);
        cn.Open();

        SqlCommand cmd = new SqlCommand("social_discussions_add", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("pid", pid);
        cmd.Parameters.AddWithValue("uname", HttpContext.Current.User.Identity.Name.ToString());
        cmd.Parameters.AddWithValue("message", txt);
        cmd.ExecuteReader();
 
    }

}
